﻿var wfbotvideo = function () {

    var _window;
    var _participant;

    $(document).ready(function () {
    });

    return {

        init: function (participant) {

            _participant = participant;

            _window = $(
				'<div id="webcallr-video-window" class="cf-video-window" style="position: absolute; top: 100; left: 400;">' +
				'	<div class="title">' +
				'		<div class="left"></div>' +
				'		<div id="webcallr-video-window-handle" class="tile">WebCallr Video</div>' +
				'		<div class="right"></div>' +
				'	</div>' +
				'	<div class="body">' +
				'		<div class="left"></div>' +
				'		<div class="tile">' +
				'			<div class="toolbar">' +
				'				<div class="left"></div>' +
				'				<div class="tile">' +
                '                   <ul id="webcallr-video-buttons">' +
                '                       <li><a id="wfbot-start-video" href="#"><div><img src="/webcallr/images/webcam.png" /></div><div>Videoyu başlatmak için tıklayın</div></a></li>' +
                '                   </ul>' +
                '               </div>' +
				'				<div class="right"></div>' +
				'			</div>' +

				'			<div class="sep"></div>' +

				'			<div id="video-wnd" class="messages">' +
                '               <object id="NovatroTalkerCtrl" classid="CLSID:20BF3749-D338-46A3-9899-5611C7FC9670" CODEBASE="http://localhost:1000/WebCallr/NovatroTalker.CAB"></object>' +
                '           </div>' +
				'			<div class="sep"></div>' +
				'		</div>' +
				'		<div class="right"></div>' +
				'	</div>' +
				'	<div class="bottom">' +
				'		<div class="left"></div>' +
				'		<div class="tile"></div>' +
				'		<div class="right"></div>' +
				'	</div>' +
				'</div>');

            $('body').append(_window);
            _window.draggable({ handle: '#webcallr-video-window-handle' });

            NovatroTalkerCtrl.Init();
            NovatroTalkerCtrl.Register("ferrari.novatro.local", "sip:bot@novatro.local", "bot", "novatro.local", "P@ssw0rd");

            $(window).unload(function () {
                NovatroTalkerCtrl.Shutdown();
            });

            $('#wfbot-start-video').click(function () {

                $.post('/communicator/getavailableoperator', null, function (result) {
                    if (result) {
                        NovatroTalkerCtrl.Call(result);
                    }
                    else {
                        alert('Şu anda size hizmet verebilecek operatör bulunmamaktadır.');
                    }
                });

            });
        }
    }

} ();
